package application;

import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JPanel;

import resources.ImageLoader;

@SuppressWarnings("serial")
class BackgroundPanel extends JPanel
{
	private Image image;
	private boolean stretch = true;
	
	
	
	
	public BackgroundPanel(String pFileName)
	{
		image = ImageLoader.chargeImage(pFileName);
	}
	
	public BackgroundPanel()
	{
		image = null;
	}

	
	
	
	public boolean isStretch() {
		return stretch;
	}

	public void setStretch(boolean stretch) {
		this.stretch = stretch;
	}

	@Override
	protected void paintComponent(Graphics g)
	{
		super.paintComponent(g); 
		
		if (image != null){
			if(stretch)
				g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
			else
				g.drawImage(image, 0,0,image.getWidth(null),image.getHeight(null),this);
		}
		/*else{
			System.out.println("image :"+image);
			g.setColor(Color.cyan);
			g.fillRect(0, 0, 100, 100);
		}*/
	}
	
	 

}
